using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CollegeShop.Infrastructure.Entities.Repository;
using CollegeShop.Infrastructure.Entities.Enum;

namespace CollegeShop.Infrastructure.Entities.Entity
{
    public class Order : IAccessible<T_Order, Order>, ILogicEntity<T_Order, Order>
    {
        public int ID { get; set; }

        public string OrderNumber { get; set; }

        public int TotalAmount { get; set; }

        public decimal TotalMoney { get; set; }

        public string BuyUser { get; set; }

        public int DormitoryID { get; set; }

        public int SalesUnitID { get; set; }

        public string LinkMan { get; set; }

        public string LinkPhone { get; set; }

        public string DeliveryAddress { get; set; }

        public string GoodsDescript { get; set; }

        public PayWay Payway { get; set; }

        public string Remark { get; set; }

        public DateTime OrderTime { get; set; }

        public ClientType OrderClient { get; set; }

        public OrderState State { get; set; }

        public string HandleUser { get; set; }

        public DateTime HandleTime { get; set; }

        public int BuyWay { get; set; }

        public int BuyClient { get; set; }

        public int AnonymousID { get; set; }

        protected override void Covariant(T_Order model)
        {
            if (model != null)
            {
                    this.ID = model.ID;
                    this.OrderNumber = model.OrderNumber;
                    this.TotalAmount = model.TotalAmount;
                    this.TotalMoney = model.TotalMoney;
                    this.BuyUser = model.BuyUser;
                    this.LinkMan = model.LinkMan;
                    this.LinkPhone = model.LinkPhone;
                    this.DormitoryID = model.DormitoryID;
                    this.DeliveryAddress = model.DeliveryAddress;
                    this.GoodsDescript = model.GoodsDescript;
                    this.Payway = (PayWay)model.Payway;
                    this.Remark = model.Remark;
                    this.OrderTime = model.OrderTime;
                    this.OrderClient = (ClientType)model.OrderClient;
                    this.State = (OrderState)model.State;
                    this.HandleUser = model.HandleUser;
                    this.SalesUnitID = model.SalesUnitID;
                    this.HandleTime = model.HandleTime;
                    this.BuyWay = model.BuyWay;
                    this.BuyClient = model.BuyClient;
                    this.AnonymousID = model.AnonymousID;
            }
}
        protected override T_Order Inverter(Order model)
        {
            if (model != null)
            {
                return new T_Order()
                {
                    ID = model.ID,
                    OrderNumber = model.OrderNumber,
                    TotalAmount = model.TotalAmount,
                    TotalMoney = model.TotalMoney,
                    BuyUser = model.BuyUser,
                    LinkMan = model.LinkMan,
                    LinkPhone = model.LinkPhone,
                    DormitoryID = model.DormitoryID,
                    DeliveryAddress = model.DeliveryAddress,
                    GoodsDescript = model.GoodsDescript,
                    Payway = (int)model.Payway,
                    Remark = model.Remark,
                    OrderTime = model.OrderTime,
                    OrderClient = (int)model.OrderClient,
                    State = (int)model.State,
                    HandleUser = model.HandleUser,
                    SalesUnitID = model.SalesUnitID,
                    HandleTime = model.HandleTime,
                    BuyWay = model.BuyWay,
                    BuyClient = model.BuyClient,
                    AnonymousID = model.AnonymousID,
                };
            }
            return null;
        }
        public Order Set(T_Order dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
